home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / example / adremove.frm next >
Text File  |  1995-05-08  |  3KB  |  139 lines

  1. VERSION 2.00
  2. Begin Form frmPractice 
  3.    Caption         =   "Add, Remove, Clear"
  4.    ClientHeight    =   3225
  5.    ClientLeft      =   1845
  6.    ClientTop       =   1620
  7.    ClientWidth     =   3615
  8.    Height          =   3630
  9.    Left            =   1785
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3225
  12.    ScaleWidth      =   3615
  13.    Top             =   1275
  14.    Width           =   3735
  15.    Begin CommandButton cmdClear 
  16.       Caption         =   "C&lear"
  17.       Height          =   372
  18.       Left            =   2400
  19.       TabIndex        =   8
  20.       Top             =   1560
  21.       Width           =   972
  22.    End
  23.    Begin CommandButton cmdRemove 
  24.       Caption         =   "&Remove"
  25.       Height          =   372
  26.       Left            =   2400
  27.       TabIndex        =   7
  28.       Top             =   960
  29.       Width           =   972
  30.    End
  31.    Begin CommandButton cmdAdd 
  32.       Caption         =   "&Add"
  33.       Height          =   372
  34.       Left            =   2400
  35.       TabIndex        =   6
  36.       Top             =   360
  37.       Width           =   972
  38.    End
  39.    Begin ListBox lstClient 
  40.       Height          =   1560
  41.       Left            =   120
  42.       Sorted          =   -1  'True
  43.       TabIndex        =   5
  44.       Top             =   840
  45.       Width           =   1812
  46.    End
  47.    Begin TextBox txtName 
  48.       Height          =   288
  49.       Left            =   120
  50.       TabIndex        =   1
  51.       Top             =   360
  52.       Width           =   1812
  53.    End
  54.    Begin CommandButton cmdEixt 
  55.       Caption         =   "&Exit"
  56.       Height          =   372
  57.       Left            =   2400
  58.       TabIndex        =   0
  59.       Top             =   2640
  60.       Width           =   972
  61.    End
  62.    Begin Label lblDisplay 
  63.       BorderStyle     =   1  'Fixed Single
  64.       Height          =   252
  65.       Left            =   960
  66.       TabIndex        =   4
  67.       Top             =   2640
  68.       Width           =   732
  69.    End
  70.    Begin Label lblClients 
  71.       Caption         =   "#Clients"
  72.       Height          =   252
  73.       Left            =   120
  74.       TabIndex        =   3
  75.       Top             =   2640
  76.       Width           =   732
  77.    End
  78.    Begin Label lblName 
  79.       Caption         =   "Name to add"
  80.       Height          =   252
  81.       Left            =   120
  82.       TabIndex        =   2
  83.       Top             =   120
  84.       Width           =   1572
  85.    End
  86. End
  87. Option Explicit
  88.  
  89. Sub cmdAdd_Click ()
  90.  
  91. Dim Client As String
  92.  
  93. If txtName.Text = "" Then
  94.    lblDisplay.Caption = lstClient.ListCount
  95. Else
  96.    Client = txtName.Text
  97.    lstClient.AddItem Client
  98.    txtName.Text = ""
  99.    lblDisplay.Caption = lstClient.ListCount
  100. End If
  101.  
  102. End Sub
  103.  
  104. Sub cmdClear_Click ()
  105.  
  106. lstClient.Clear
  107. lblDisplay.Caption = lstClient.ListCount
  108.  
  109. End Sub
  110.  
  111. Sub cmdEixt_Click ()
  112.  
  113. Beep
  114. End
  115.  
  116. End Sub
  117.  
  118. Sub cmdRemove_Click ()
  119.  
  120. Dim Ind As Integer
  121.  
  122. Ind = lstClient.ListIndex
  123. If Ind >= 0 Then
  124.    lstClient.RemoveItem Ind
  125.    lblDisplay.Caption = lstClient.ListCount
  126. Else
  127.    Beep
  128. End If
  129.  
  130. End Sub
  131.  
  132. Sub Form_Load ()
  133.  
  134. ' Initialize # of client to 0.
  135.     lblDisplay.Caption = "0"
  136.  
  137. End Sub
  138.  
  139.